package server.controller.goodController;

import base.BaseValue;
import server.entity.Good;
import server.model.factory.ModelFactory;
import server.util.InfoUtils.Info;
import server.util.MyUtils;
import server.util.ResponseUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/setGoodInfo")
@MultipartConfig(maxFileSize = 50000000)
public class SetGoodInfoServlet extends HttpServlet {

    private static final long serialVersionUID = 736796119234478475L;

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Good good = MyUtils.convertRequest2Bean(req, Good.class, BaseValue.picLoad, "good-pic-");
        Info info = ModelFactory.getGoodInfoModel().setGoodInfo(good);
        ResponseUtil.responseMessage(resp, info);
    }
}
